package com.smh.a02streamDemo1;

import java.util.ArrayList;

public class StreamDemo1 {
    public static void main(String[] args) {

        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.add("sad");
        arrayList.add("qwe");
        arrayList.add("zxc");
        arrayList.add("shjwq");
        arrayList.add("tyu");

        ArrayList<String> list = new ArrayList<>();

        //选s开头的
        for (String s : arrayList) {
            if (s.startsWith("s")) {
                list.add(s);
            }
        }

        System.out.println(list);

        ArrayList<String> list1 = new ArrayList<>();
        //选s开头,并且长度为三
        for (String s : list) {
            if (s.length() == 3) {
                list1.add(s);
            }
        }

        System.out.println(list1);

        //stream流
        list1.stream().filter(name->name.startsWith("s")).filter(name->name.length()==3).forEach(s -> System.out.println(s));


    }
}
